package com.atguigu.ware.dao;

import com.atguigu.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 *
 * @author polarisink
 * @email polarisink@163.com
 * @date 2020-12-18 15:40:40
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

  /**
   * 添加库存
   *
   * @param skuId
   * @param wareId
   * @param skuNum
   */
  void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);

  /**
   * 获取库存
   *
   * @param skuId
   * @return
   */
  Long getSkuStock(Long skuId);

  List<Long> listWareIdsHasStock(@Param("skuId") Long skuId, @Param("count") Integer count);

  Long lockWareSku(@Param("skuId") Long skuId, @Param("num") Integer num, @Param("wareId") Long wareId);

  void unlockStock(@Param("skuId") Long skuId, @Param("skuNum") Integer skuNum, @Param("wareId") Long wareId);
}
